package com.example.demo.dao;

import com.example.demo.entity.EmailMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Hy on 2018/8/3.
 */
public interface EmailMessageDao extends JpaRepository<EmailMessage,Integer> {
    @Query(value="SELECT u FROM EmailMessage u WHERE u.status =1")
    List<EmailMessage> findEmailMsgByStatus();

    @Transactional
    @Modifying
    @Query("update EmailMessage sc set sc.status = 2 where sc.userId = ?1")
    Integer updateStatusById(long id);
}
